#pragma once
#include<iostream>
#include<pthread.h>
#include<string>
#include<ctime>
using namespace std;
typedef void(*call_t)();
static int num=1;
class thread
{
public:
static void*fun(void*args)
{
  thread* ts=static_cast<thread*>(args);
  ts->entery();
  return (void*)0;
}

public:
thread(call_t cb)
:tid_(0)
,name_("")
,time_start_(0)
,isrunning_(false)
,cb_(cb)
{



}
void run()
{
name_="thread-"+to_string(num++);
time_start_=time(nullptr);
isrunning_=true;
pthread_create(&tid_,nullptr,fun,this);

}
u_int64_t get_time()
{

return time_start_;
}
string get_name()
{
return name_;
}
bool isrun()
{
return isrunning_;
}
void entery()
{
 
 cb_();




}





void Join()
{
 pthread_join(tid_,nullptr);
 isrunning_=false;
}
~thread()
{



}








private:
string name_;
u_int64_t time_start_;
bool isrunning_;
pthread_t tid_;
call_t cb_;


};